<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:sec="https://www.thymeleaf.org/thymeleaf-extras-springsecurity5"
      xmlns:th="https://www.thymeleaf.org">
<head>
    <title>Spring Security OAuth 2.0 Sample</title>
    <meta charset="utf-8"/>
    <meta content="IE=edge" http-equiv="X-UA-Compatible"/>
    <meta content="width=device-width, initial-scale=1, shrink-to-fit=no" name="viewport">
    <link href="/webjars/bootstrap/css/bootstrap.css" rel="stylesheet"
          th:href="@{/webjars/bootstrap/css/bootstrap.css}"/>
</head>
<body>
<div th:fragment="header">
    <nav class="navbar navbar-default">
        <div class="container">
            <div class="container-fluid">
                <div class="navbar-collapse collapse" id="navbar">
                    <ul class="nav navbar-nav navbar-right">
                        <li class="dropdown">
                            <a aria-expanded="false" aria-haspopup="true" class="dropdown-toggle" data-toggle="dropdown" href="#"
                               id="user-menu" role="button">
                                <span sec:authentication="name">User</span>
                            </a>
                            <ul class="dropdown-menu">
                                <li><a href="javascript:document.logoutForm.submit()" id="sign-out">Sign Out</a></li>
                            </ul>
                            <form method="post" name="logoutForm" th:action="@{/logout}" th:hidden="true">
                                <input hidden type="submit" value="Sign Out"/>
                            </form>
                        </li>
                    </ul>
                </div>
            </div>
        </div>
    </nav>
</div>
<div class="container">
    <div class="panel panel-default">
        <div class="panel-heading">
            <h3 class="panel-title">Authorize the client with <span style="font-family:monospace">grant_type</span>:
            </h3>
        </div>
        <ul class="list-group">
            <li class="list-group-item">
                <a href="/authorize?grant_type=authorization_code"
                   th:href="@{/authorize?grant_type=authorization_code}"><span style="font-size:medium">Authorization Code</span></a>
            </li>
            <li class="list-group-item">
                <a href="/authorize?grant_type=client_credentials"
                   th:href="@{/authorize?grant_type=client_credentials}"><span style="font-size:medium">Client Credentials</span></a>
            </li>
            <li class="list-group-item">
                <div>
                    <p style="font-size:medium">Resource Owner Password Credentials</p>
                    <form method="post" th:action="@{/authorize}">
                        <div class="form-row">
                            <div class="form-group">
                                <label for="username" style="font-size:small">Username</label>
                                <input class="form-control input-sm" id="username" name="username" type="text">
                                <small class="form-text text-muted">user / password</small>
                            </div>
                        </div>
                        <div class="form-row">
                            <div class="form-group">
                                <label for="password" style="font-size:small">Password</label>
                                <input class="form-control input-sm" id="password" name="password" type="password">
                            </div>
                        </div>
                        <input id="grant_type" name="grant_type" type="hidden" value="password">
                        <button class="btn btn-primary btn-sm" type="submit">Authorize</button>
                    </form>
                </div>
            </li>
        </ul>
        <div class="panel-footer" th:if="${messages}">
            <h4>Messages:</h4>
            <table class="table table-condensed">
                <tbody>
                <tr class="row" th:each="message : ${messages}">
                    <td th:text="${message}">message</td>
                </tr>
                </tbody>
            </table>
        </div>
    </div>
</div>
<script src="/webjars/jquery/jquery.min.js" th:src="@{/webjars/jquery/jquery.min.js}"></script>
<script src="/webjars/bootstrap/js/bootstrap.min.js" th:src="@{/webjars/bootstrap/js/bootstrap.min.js}"></script>
</body>
</html>
